<?php

namespace App\Http\Controllers\Admin\Area;

use App\Exceptions\BasicException;
use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;    //引用http请求类
use App\Response\Response;

class ProvinceController extends BaseController {

    /**
     * @api {get} /area/province 省级行政单位数据-获取省份列表
     * @apiVersion 0.1.0
     * @apiName 区域信息-省级行政单位数据-获取省份列表
     * @apiGroup 区域信息
     *
     *
     * @apiSuccessExample 成功响应
     *
     *
    {
        "code": 200,
        "data": [
            {
                "district_id(省份id)": 110000,
                "name(名称)": "北京"
            }
        ]
    }
     *
     *
     */
    public function list(Request $request) {

        $allProvince = app('repo_area')->getAllProvinceList();

        $result = [];
        foreach ($allProvince as $item) {
            $result[] = [
                "district_id" => $item['district_id'],
                "name" => $item['name'],
            ];
        }

        return Response::sendData($result);
    }

}
